//当前模块不会直接执行,需要将内容导出,在其他代码中import导入使用
import request from '@/utils/request'
export default {
    //1.查询所有讲师
    teacherList() {
        return request({
            url: 'admin/edu/teacher/list',//请求地址,会和baseURL拼接
            method: 'get'
        })
    },
    //2.分页查询讲师
    teacherPage(page, limit, searchObj) {
        return request({
            url: `admin/edu/teacher/list/${page}/${limit}`,
            method: "get",
            params: searchObj //表示查询的条件对象, ps:{name: level: joinDateBegin:}
        })
    },
    //3.更新讲师
    teacherUpdate(teacher){
        return request({
            url:'admin/edu/teacher/update',
            method:'put',
            data:teacher
        })
    },
    //4.删除指定讲师的方法
    teacherRemove(id) {
        return request({
            url: `admin/edu/teacher/remove/${id}`,
            method: 'delete'
        })
    },
    //5.新增讲师
    // teacherSave:function(){}
    teacherSave(teacher) {
        return request({
            url:'admin/edu/teacher/save',
            method:'post',
            //data提交的数据,后台必须通过@RequestBody入参
            //params提交的数据,后台通过@RequestParam入参
            data:teacher // teacher是收集了讲师信息的json对象{k:v..}
        })
    },
    //6.根据id查询讲师
    teacherQueryById(id){
        return request({
            url:`admin/edu/teacher/get/${id}`,
            method:'get'
        })
    },
    //7.批量删除讲师
    teacherBatchRemove(ids){
        return request({
            url:'admin/edu/teacher/batch-remove',
            method:'delete',
            data: ids
        })
    },
    //8.自动补全查询条件
    selectNameListByKey(key){
        return request({
            url:`/admin/edu/teacher/list/name/${key}`,
            method:'get'
        })
    }
}